package com.r7data.dbstruct.code;

public class ValueMetaCode {
	/** Value type indicating that the value has no type set */
	public static final int TYPE_NONE = 0;

	/**
	 * Value type indicating that the value contains a floating point double
	 * precision number.
	 */
	public static final int TYPE_NUMBER = 1;

	/** Value type indicating that the value contains a text String. */
	public static final int TYPE_STRING = 2;

	/** Value type indicating that the value contains a Date. */
	public static final int TYPE_DATE = 3;

	/** Value type indicating that the value contains a boolean. */
	public static final int TYPE_BOOLEAN = 4;

	/** Value type indicating that the value contains a long integer. */
	public static final int TYPE_INTEGER = 5;

	/**
	 * Value type indicating that the value contains a floating point precision
	 * number with arbitrary precision.
	 */
	public static final int TYPE_BIGNUMBER = 6;

	/** Value type indicating that the value contains an Object. */
	public static final int TYPE_SERIALIZABLE = 7;

	/**
	 * Value type indicating that the value contains binary data: BLOB, CLOB,
	 * ...
	 */
	public static final int TYPE_BINARY = 8;

	/**
	 * Value type indicating that the value contains a date-time with nanosecond
	 * precision
	 */
	public static final int TYPE_TIMESTAMP = 9;

	/** Value type indicating that the value contains a Internet address */
	public static final int TYPE_INET = 10;

	/** The Constant typeCodes. */
	public static final String[] typeCodes = { "-", "Number", "String", "Date", "Boolean", "Integer", "BigNumber",
			"Serializable", "Binary", "Timestamp", "Internet Address" };

	/** The storage type is the same as the indicated value type */
	public static final int STORAGE_TYPE_NORMAL = 0;

	/**
	 * The storage type is binary: read from text but not yet converted to the
	 * requested target data type, for lazy conversions.
	 */
	public static final int STORAGE_TYPE_BINARY_STRING = 1;

	/** indexed **/
	public static final int STORAGE_TYPE_INDEXED = 2;

	/** 存储 */
	public static final String[] storageTypeCodes = { "normal", "binary-string", "indexed", };

	/** clob 长度 **/
	public static final int CLOB_LENGTH = 9999999;
	
	/** 小数点符号 **/
	public static final String decimal_symbol = ".";
	/** 数字分组符号 **/
	public static final String groupingSymbol = ",";
	
	public static final int TRIM_TYPE_NONE = 0;
	public static final int TRIM_TYPE_LEFT = 1;
	public static final int TRIM_TYPE_RIGHT = 2;
	public static final int TRIM_TYPE_BOTH = 3;
	public static final String[] trimTypeCodes = { "none", "left", "right", "both" };
	
	
	/**
	 * 获得映射到 java 的字段类型
	 * 
	 * @param codeNumber
	 * @return
	 */
	public static String getValTypeName(int codeNumber) {
		int index = 0;

		if (codeNumber <= typeCodes.length && codeNumber >= 0) {
			index = codeNumber;
		}

		String valTypeName = typeCodes[index];

		return valTypeName;
	}

	/**
	 * 存储类型
	 * @param storageType
	 * @return
	 */
	public static String getStorageTypeCode(int storageType){
		String typeCode = null;
		
		if ( storageType >= STORAGE_TYPE_NORMAL && storageType <= STORAGE_TYPE_INDEXED ) {
			typeCode = storageTypeCodes[storageType];
		}
		return typeCode;
	}
	
	/**
	 * 是否去除空格
	 * @param trimeType
	 * @return
	 */
	public static String getTrimTypeCode(int trimType){
		String trimTypeCode = null;
		
		if ( trimType >= TRIM_TYPE_NONE && trimType <= TRIM_TYPE_BOTH ) {
			trimTypeCode = trimTypeCodes[trimType];
		}
		return trimTypeCode;
	}

}
